// pages/Goods/goodsOrderQRCode/index.js
const QRCode = require('../../../../utils/weapp-qrcodes.js')
Page({

  /**
   * 页面的初始数据
   */
  data: {
    qrcode: null,
    title:"",
    orderNo:"",
    orderTime:"",
    paymentTime: "",
    address:"",
    mobile:"",
    orderId:"",
    userId: "",
    qrcodePath:"",
    imgs:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      title: options.title,
      orderNo: options.orderNo,
      orderTime: options.orderTime,
      paymentTime: options.paymentTime,
      address: options.address,
      mobile: options.mobile,
      orderId: options.orderId,
      userId: options.userId
    }, _ => {
      // this.createQRCode()
    })
  },
  onShow(){
    if( this.data.orderId && this.data.userId) {
      this.createQRCode()
    }
  },
  createQRCode() {
    var that = this
    // console.log('嘻哈嘻哈--','feiyangstore/sendgoods/order_id=' + this.data.orderId + '&user_id:' + this.data.userId);
   
    var qrcode = new QRCode('canvas', {
      text: 'feiyangstore/sendgoods/order_id=' + this.data.orderId + '&user_id:' + this.data.userId,
      // text:'https://api.feiyanghy.com',
      width: 150,
      height: 150,
      callback: (res) => {  
        console.log(res.path)
        that.setData({
          imgs:res.path
        })
    }
    })
  },
  contact() {
    const mobile = this.data.mobile
    wx.makePhoneCall({
      phoneNumber: mobile
    })
  },

})